package org.testmyapp.entities;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.testmyapp.persistence.BusinessObjectMarker;

@Entity
public class Contract extends AbsProcessRelatedObject implements BusinessObjectMarker {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1256641639706094181L;
	
	public static String tableName = "Contract";
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	@JoinColumn(name="person_fk")
	private Person contractHolder;

	//Basically the begin...
	@Temporal(value=TemporalType.DATE)
	private Date beginDateTechnical;
	
	//....unless it's before this date (signing of contract)
	@Temporal(value=TemporalType.DATE)
	private Date beginDateFormal;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Person getContractHolder() {
		return contractHolder;
	}
	public void setContractHolder(Person contractHolder) {
		this.contractHolder = contractHolder;
	}
	public Date getBeginDateTechnical() {
		return beginDateTechnical;
	}
	public void setBeginDateTechnical(Date beginDateTechnical) {
		this.beginDateTechnical = beginDateTechnical;
	}
	public Date getBeginDateFormal() {
		return beginDateFormal;
	}
	public void setBeginDateFormal(Date beginDateFormal) {
		this.beginDateFormal = beginDateFormal;
	}
	
	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof Contract) || o == null)
			return false;
		Contract other = (Contract) o;
		if ((this.getContractHolder() == null && other.getContractHolder() != null)
				|| (!this.getContractHolder().equals(other.getContractHolder()))) {
			return false;
		}
		if ((this.getBeginDateTechnical() == null && other.getBeginDateTechnical() != null)
				|| !this.getBeginDateTechnical().equals(other.getBeginDateTechnical())) {
			return false;
		}
		if ((this.getBeginDateFormal() == null && other.getBeginDateFormal() != null)
				|| !this.getBeginDateFormal().equals(other.getBeginDateFormal())) {
			return false;
		}
		if ((this.getId() == null && other.getId() != null)
				|| !this.getId().equals(other.getId())) {
			return false;
		}
		return true;
	}
	
}
